#pragma once
#include <iostream>
#include <string>
#include <functional>
#include "Reactor.hpp"
class Connection;
class Reactor;
using func_t = std::function<void(Connection*)>;
class Connection
{
    public:
        Connection(int sock) : _sock(sock)
        {
        }
        void SetReactor(Reactor* R)
        {
            _R = R;
        }
        void Register(func_t recv , func_t send , func_t except)
        {
            _recv = recv;
            _send = send;
            _except = except;
        }
        void SetEvents(uint32_t events)
        {
            _events = events;
        }
        uint32_t Events()
        {
            return _events;
        }
        int Sockfd()
        {
            return _sock;
        }
    private:
        int _sock;
        std::string _inbuffer;
        std::string _outbuffer;
        uint32_t _events;
    public:
        func_t _recv;
        func_t _send;
        func_t _except;
        Reactor* _R; 
};